﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;


namespace OctopusWebInterface
{
    public partial class VirtualMachines : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            var body = this.Master.FindControl("MyBody") as HtmlGenericControl;
            body.Attributes.Add("onload", "OnPageLoad()");

            if (!this.IsPostBack)
            {
                Octopus.OctopusLib.VMTemplate[] templates;
                try
                {
                    templates = Octopus.OctopusLib.Functions.getAllVmTemplates();
                }
                catch
                {
                    return;
                }
                
                this.DropDownList_VmTemplates.Items.Clear();
                this.DropDownList_VmTemplates.Items.Add(new ListItem("",""));

                foreach (var t in templates)
                {
                    ListItem item = new ListItem(t.Name, t.ID.ToString());
                    item.Attributes.Add("title", t.Description);
                    this.DropDownList_VmTemplates.Items.Add(item);
                }
            }
        }
    }
}